// 点击账号登录或者扫码登录切换
let loginss = document.querySelectorAll(".login-box div")
let loginqwer = document.querySelectorAll(".loginqwer")
let index = 0
// console.log(loginqwer);
// console.log(loginss);
loginss.forEach(function (v, i) {
    // console.log(v);
    v.addEventListener("click", function () {
        loginss[index].className = ""
        loginqwer[index].style.display = "none"
        v.className = "loginss"
        loginqwer[i].style.display = "flex"
        index = i
    })
})
let texts = document.querySelector("#texts")
let password = document.querySelector("#password")
let icon = document.querySelector(".icon")
let eyes = document.querySelector(".eyes")
// console.log(text, password)
// texts.addEventListener("input", function () {
//     if (texts.value.length > 0) {
//         icon.style.display = "block"
//     } else {
//         icon.style.display = "none"

//     }
// });
// password.addEventListener("input", function () {
//     if (password.value.length > 0) {
//         eyes.style.display = "block"
//     } else {
//         eyes.style.display = "none"

//     }
// });
let inputs = document.querySelectorAll(".loginqwer input ")
let closeds = document.querySelector(".icon-closed")
console.log(open);
// console.log(inputs);
inputs.forEach(function (v) {
    v.addEventListener("input", function () {
        if (v.value.length > 0 && v.className === "text") {
            icon.style.display = "block"

        } else {
            icon.style.display = "none"

        }

        if (v.value.length > 0 && v.className === "password") {
            eyes.style.display = "block"
            closeds.style.display = "block"
        } else {
            eyes.style.display = "none"

        }

    })

})
// 点击叉叉，清楚账号或者密码的数据和眼睛
let clears = document.querySelectorAll(".loginqwer i")
// console.log(clears);
clears.forEach(function (v) {
    // console.log(v);
    v.addEventListener("click", function () {
        if (v.className === "icon") {
            texts.value = ""
            v.style.display = "none"

        } else {
            password.value = ""
            v.style.display = "none"
            closeds.style.display = "none"
        }
    })
})
// 点击眼睛图标切换和密码显示与隐藏
let passwords = document.querySelector(".password")
// console.log(passwords);
closeds.addEventListener("click", function () {
    if (passwords.type == "password") {
        closeds.classList.remove("icon-closed")
        closeds.classList.add("icon-open")
        closeds.style.display = "block"
        passwords.type = "text"
    } else {
        closeds.classList.remove("icon-open")
        closeds.classList.add("icon-closed")
        closeds.style.display = "block"
        passwords.type = "password"
    }

})
